package dataStructures;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class CBElements implements WritableComparable<CBElements> {

	private int ratingsCounter;
	private int ratingsSum; 

		

        public CBElements(int ratingsCounter, int ratingsSum) {
		this.ratingsCounter = ratingsCounter;
		this.ratingsSum = ratingsSum;
	}

		@Override
        public void write(DataOutput out) throws IOException {
        	out.writeInt(ratingsCounter);
        	out.writeInt(ratingsSum);
        }

        @Override
        public void readFields(DataInput in) throws IOException {
                ratingsCounter = in.readInt();
                ratingsSum = in.readInt();
                
        }

        @Override
        public int compareTo(CBElements o) {

                boolean equals = true;
                if(ratingsCounter != o.ratingsCounter)
                	equals = false;
                if(ratingsSum != o.ratingsSum)
                	equals = false;
                	
                if (equals)
                        return 0;
                else
                        return 1;
        }
        
        public int getRatingsCounter(){
        	return ratingsCounter;
        }
        
    	public int getRatingsSum(){
    		return ratingsSum;
    	}



        @Override
        public String toString() {
                return "<" + ratingsCounter + "," + ratingsSum + ">";
        }

}